<?php
session_start();
ob_start();
include_once 'include/common.php';
$core = new core();
if (!$core->CheckLogin()) {
    header('Location:login.php');
}
$customer_id = isset($_GET["id"]) ? intval($_GET["id"]) : 0;
if ($customer_id > 0) {
    $customer = $core->getCustomerById($customer_id);
    if (!$customer) {
        header("location:customerList.php");
    }
}
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <!--
                Charisma v1.0.0

                Copyright 2012 Muhammad Usman
                Licensed under the Apache License v2.0
                http://www.apache.org/licenses/LICENSE-2.0

                http://usman.it
                http://twitter.com/halalit_usman
        -->
        <meta charset="utf-8">
        <title>Zen store</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="Charisma, a fully featured, responsive, HTML5, Bootstrap admin template.">
        <meta name="author" content="Muhammad Usman">

        <!-- The styles -->
        <link id="bs-css" href="css/bootstrap-cerulean.css" rel="stylesheet">
        <style type="text/css">
            body {
                padding-bottom: 40px;
            }
            .sidebar-nav {
                padding: 9px 0;
            }
        </style>
        <link href="css/bootstrap-responsive.css" rel="stylesheet">
        <link href="css/charisma-app.css" rel="stylesheet">
        <link href="css/style.css" rel="stylesheet">
        <link href="css/jquery-ui-1.8.21.custom.css" rel="stylesheet">

        <link href='css/chosen.css' rel='stylesheet'>
        <link href='css/uniform.default.css' rel='stylesheet'>

        <link href='css/jquery.cleditor.css' rel='stylesheet'>


        <link href='css/jquery.iphone.toggle.css' rel='stylesheet'>

        <link href='css/uploadify.css' rel='stylesheet'>

        <!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
          <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

        <!-- The fav icon -->
        <link rel="shortcut icon" href="img/favicon.ico">

    </head>

    <body>
        <div id="page-wrap" class="page-wrap body-wrap ">
            <div id="page-tray" class="tray transition">
                <?php include_once ('new_menu.php'); ?>

                <div id="page-content" class="page-content transition profile-page">
                    <?php include_once ('navbar.php'); ?>
                    <div class="container-fluid">
                        <div class="row-fluid">
                            <div id="content" class="span12">
<!--                                <div>
                                    <ul class="breadcrumb">
                                        <li>
                                            <a href="#">Home</a> <span class="divider">/</span>
                                        </li>
                                        <li>
                                            <a href="#">Forms</a>
                                        </li>
                                    </ul>
                                </div>-->

                                <div class="row-fluid sortable">
                                    <div class="box span12">
                                        <div class="box-header well" data-original-title>
                                            <h2><i class="icon-edit"></i> Thêm khách hàng</h2>
                                            <div class="box-icon">
<!--                                                <a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>-->
                                                <a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
<!--                                                <a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>-->
                                            </div>
                                        </div>
                                        <div class="box-content">
                                            <form class="form-horizontal" id="form_customer">
                                                <fieldset>

                                                    <div class="control-group">
                                                        <label class="control-label" for="product_name">Tên khách hàng </label>
                                                        <div class="controls">
                                                            <input type="text" class="span6 typeahead" id="customer_name" value="<?php if ($customer_id > 0) echo $customer->name; ?>" >
                                                        </div>
                                                    </div>
                                                    <div class="control-group">
                                                        <label class="control-label" for="customer_fb_name">Tên facebook* </label>
                                                        <div class="controls">
                                                            <input type="text" class="span6 typeahead" id="customer_fb_name" value="<?php if ($customer_id > 0) echo $customer->facebook_name; ?>"   >

                                                        </div>
                                                    </div>
                                                    <div class="control-group">
                                                        <label class="control-label" for="customer_fb_link">Link facebook </label>
                                                        <div class="controls">
                                                            <input type="text" class="span6 typeahead" id="customer_fb_link" value="<?php if ($customer_id > 0) echo $customer->facebook_link; ?>"  >

                                                        </div>
                                                    </div>
                                                     <div class="control-group">
                                                        <label class="control-label" for="customer_email">Email </label>
                                                        <div class="controls">

                                                            <input type="text" class="span6 typeahead" id="customer_email" value="<?php if ($customer_id > 0) echo $customer->email; ?>"   >

                                                        </div>
                                                    </div>
                                                    <div class="control-group">
                                                        <label class="control-label" for="customer_phone">Số phone* </label>
                                                        <div class="controls">

                                                            <input type="text" class="span6 typeahead" id="customer_phone" value="<?php if ($customer_id > 0) echo $customer->phone; ?>"   >

                                                        </div>
                                                    </div>
                                                    <div class="control-group">
                                                        <label class="control-label" for="customer_extra_phone">Số phone phụ </label>
                                                        <div class="controls">
                                                            <input type="text" class="span6 typeahead" id="customer_extra_phone" value="<?php if ($customer_id > 0) echo $customer->extra_phone; ?>"  >

                                                        </div>
                                                    </div>
                                                    <div class="control-group">
                                                        <label class="control-label" for="customer_address">Địa chỉ </label>
                                                        <div class="controls">
                                                            <input type="text" class="span6 typeahead" id="customer_address" value="<?php if ($customer_id > 0) echo $customer->address; ?>"  >

                                                        </div>
                                                    </div>
                                                    <div class="control-group">
                                                        <label class="control-label" for="customer_size">Size quần áo </label>
                                                        <div class="controls">
                                                            <input type="text" class="span6 typeahead" id="customer_size" value="<?php if ($customer_id > 0) echo $customer->clothes_size; ?>"  >

                                                        </div>
                                                    </div>
                                                    <div class="control-group">
                                                        <label class="control-label" for="customer_bank_account">Tài khoản ngân hàng </label>
                                                        <div class="controls">
                                                            <input type="text" class="span6 typeahead" id="customer_bank_account"  value="<?php if ($customer_id > 0) echo $customer->bank_account; ?>" >

                                                        </div>
                                                    </div>
                                                    <div class="control-group">
                                                        <label class="control-label" for="customer_province">Tỉnh </label>
                                                        <div class="controls">
                                                            <label class="checkbox inline">
                                                                <div class="checker" id="uniform-inlineCheckbox1"><span class=""><input type="checkbox" value="1" id="customer_province" style="opacity: 0;" <?php if ($customer_id > 0 && $customer->province == 1) echo "checked=checked"; ?>></span></div>
                                                            </label>

                                                        </div>
                                                    </div>
                                                    <div class="control-group">
                                                        <label class="control-label" for="customer_wholesale">Khách buôn </label>
                                                        <div class="controls">
                                                            <label class="checkbox inline">
                                                                <div class="checker" id="uniform-inlineCheckbox1"><span class=""><input type="checkbox" value="1" id="customer_wholesale" style="opacity: 0;" <?php if ($customer_id > 0 && $customer->wholesale == 1) echo "checked=checked"; ?>></span></div>
                                                            </label>

                                                        </div>
                                                    </div>
                                                    <div class="control-group">
                                                        <label class="control-label" for="customer_vip" >VIP </label>
                                                        <div class="controls">
                                                            <select id="customer_vip" >
                                                                <option value="0" <?php if ($customer_id > 0 && $customer->VIP == 0) echo "selected=selected"; ?>>Không</option>
                                                                <option value="1" <?php if ($customer_id > 0 && $customer->VIP == 1) echo "selected=selected"; ?>>VIP</option>
                                                                <option value="2" <?php if ($customer_id > 0 && $customer->VIP == 2) echo "selected=selected"; ?>>Black list</option>
                                                            </select>

                                                        </div>
                                                    </div>
                                                    <div class="control-group">
                                                        <label class="control-label" ></label>
                                                        <div class="controls">
                                                            <div class="alert alert-error" id="alert-error-customer" style="display:none">
                                                            </div>

                                                        </div>
                                                    </div>
                                                    <div class="form-actions">
                                                        <input type="hidden" name="customer_id" id="customer_id" value="<?php if ($customer_id > 0)
                        echo $customer_id;
                    else
                        echo "0";
                    ?>">
                                                        <button type="button" class="btn btn-primary" id="btn_save_customer">Save changes</button>
                                                        <button type="reset" class="btn">Cancel</button>
                                                    </div>
                                                </fieldset>
                                            </form>   

                                        </div>
                                    </div><!--/span-->

                                </div><!--/row-->


                                <div class="row-fluid sortable">
                                    <div class="box span12">
                                        <div class="box-header well" data-original-title>
                                            <h2><i class="icon-edit"></i> Import khách hàng</h2>
                                            <div class="box-icon">
<!--                                                <a href="#" class="btn btn-setting btn-round"><i class="icon-cog"></i></a>-->
                                                <a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
<!--                                                <a href="#" class="btn btn-close btn-round"><i class="icon-remove"></i></a>-->
                                            </div>
                                        </div>
                                        <div class="box-content">
                                            <form class="form-horizontal form_upload_file" name="form_upload_file" id="form_upload_file" method="post" enctype="multipart/form-data" action="ajax/uploadFileCustomer.php" target="upload_target">
                                                <fieldset>
                                                    <div class="control-group">
                                                        <label class="control-label" for="fileInput">File input</label>
                                                        <div class="controls upload-btn">
                                                            <input class="input-file uniform_on" id="input_upload_file" type="file" name="file">
                                                        </div>
                                                    </div> 
                                                    <div class="form-actions">
                                                        <button type="submit" class="btn btn-primary">Save changes</button>
                                                        <button class="btn">Cancel</button>
                                                    </div>
                                                </fieldset>
                                            </form>
                                            <iframe id="upload_target" name="upload_target" src=""></iframe>

                                        </div>
                                    </div><!--/span-->

                                </div><!--/row-->
</div>
                          
                        </div><!--/fluid-row-->
                        <?php include_once ('footer.php'); ?>


                    </div><!--/.fluid-container-->

                    <!-- external javascript
                    ================================================== -->
                    <!-- Placed at the end of the document so the pages load faster -->

                    <!-- jQuery -->
                    <script src="js/jquery-1.7.2.min.js"></script>
                    <!-- jQuery UI -->
                    <script src="js/jquery-ui-1.8.21.custom.min.js"></script>
                    <!-- transition / effect library -->
                    <script src="js/bootstrap-transition.js"></script>
                    <!-- alert enhancer library -->
                    <script src="js/bootstrap-alert.js"></script>
                    <!-- modal / dialog library -->
                    <script src="js/bootstrap-modal.js"></script>
                    <!-- custom dropdown library -->
                    <script src="js/bootstrap-dropdown.js"></script>
                    <!-- scrolspy library -->
                    <!--	<script src="js/bootstrap-scrollspy.js"></script>-->
                    <!-- library for creating tabs -->
                    <script src="js/bootstrap-tab.js"></script>
                    <!-- library for advanced tooltip -->
                    <script src="js/bootstrap-tooltip.js"></script>
                    <!-- popover effect library -->
                    <script src="js/bootstrap-popover.js"></script>
                    <!-- button enhancer library -->
                    <!--	<script src="js/bootstrap-button.js"></script>-->
                    <!-- accordion library (optional, not used in demo) -->
                    <script src="js/bootstrap-collapse.js"></script>
                    <!-- carousel slideshow library (optional, not used in demo) -->
                    <!--	<script src="js/bootstrap-carousel.js"></script>-->
                    <!-- autocomplete library -->
                    <!--	<script src="js/bootstrap-typeahead.js"></script>-->
                    <!-- tour library -->
                    <!--	<script src="js/bootstrap-tour.js"></script>-->
                    <!-- library for cookie management -->
                    <script src="js/jquery.cookie.js"></script>
                    <script src='js/jquery.dataTables.min.js'></script>
                    <!-- calander plugin -->
                    <!--	<script src='js/fullcalendar.min.js'></script>
                     data table plugin 
                    -->

                    <!-- chart libraries start -->
                    <!--	<script src="js/excanvas.js"></script>
                    <script src="js/jquery.flot.min.js"></script>
                    <script src="js/jquery.flot.pie.min.js"></script>
                    <script src="js/jquery.flot.stack.js"></script>
                    <script src="js/jquery.flot.resize.min.js"></script>-->
                    <!-- chart libraries end -->

                    <!-- select or dropdown enhancer -->
                    <script src="js/jquery.chosen.min.js"></script>
                    <!-- checkbox, radio, and file input styler -->
                    <script src="js/jquery.uniform.min.js"></script>
                    <!-- plugin for gallery image view -->
                    <!--	<script src="js/jquery.colorbox.min.js"></script>-->
                    <!-- rich text editor library -->
                    <script src="js/jquery.cleditor.min.js"></script>
                    <!-- notification plugin -->
                    <!--	<script src="js/jquery.noty.js"></script>-->
                    <!-- file manager library -->
                    <!--	<script src="js/jquery.elfinder.min.js"></script>-->
                    <!-- star rating plugin -->
                    <!--	<script src="js/jquery.raty.min.js"></script>-->
                    <!-- for iOS style toggle switch -->
                    <script src="js/jquery.iphone.toggle.js"></script>
                    <!-- autogrowing textarea plugin -->
                    <script src="js/jquery.autogrow-textarea.js"></script>
                    <!-- multiple file upload plugin -->
                    <script src="js/jquery.uploadify-3.1.min.js"></script>
                    <!-- history.js for cross-browser state change on ajax -->
                    <script src="js/jquery.history.js"></script>
                    <!-- application script for Charisma demo -->
                    <script src="js/common.js?t=1"></script>
                    <script src="js/addCustomer.js?t=5"></script>
                </div>
            </div>
        </div>


    </body>
</html>

